package com.example.config;

import com.example.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Component
public class WebMvcConfig implements WebMvcConfigurer {
    @Bean
    public LoginInterceptor getLoginInterceptor() {
        return new LoginInterceptor();
    }
    /**
     * 拦截器配置
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getLoginInterceptor())
                // 拦截路劲
                .addPathPatterns("/**")
                // 排除路径
                .excludePathPatterns("/user/login.do")
                .excludePathPatterns("/jsp/login.jsp")
                .excludePathPatterns("/ckeditor/**")
                .excludePathPatterns("/script/**")
                .excludePathPatterns("/style/**");
    }
}